{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "5bbc2701",
   "metadata": {},
   "source": [
    "------\n",
    "* 2022-9-06\n",
    "* python课堂笔记\n",
    "* 记录人:梁颖"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7aec5f2a",
   "metadata": {},
   "source": [
    "# 本周知识点\n",
    "> 1. 回顾变量的概念\n",
    "> 2. 条件判断\n",
    "> 3. for循环和range方法\n",
    "> 4. random模块（伪随机数模块）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4200eaf9",
   "metadata": {},
   "source": [
    "## 1. 回顾变量的概念"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f51e278f",
   "metadata": {},
   "outputs": [],
   "source": [
    "网新_01_ID = \"21000001\"\n",
    "网新_02_ID = \"21000002\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "15fa4be7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'21000001'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网新_01_ID"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "6cf028e2",
   "metadata": {},
   "outputs": [],
   "source": [
    "网新_01_Age = \"18\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "19a89f3f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'18'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网新_01_Age"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8b2b3e12",
   "metadata": {},
   "source": [
    "## 2. 条件判断"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c0983261",
   "metadata": {},
   "source": [
    "## 3. 上节课课后作业\n",
    "### （详情见week02 : 第一章-快速入门）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b2b698aa",
   "metadata": {},
   "source": [
    "## 4. for循环和range方法\n",
    "### （详情见week02 : 第一章-快速入门）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fb7a7eb1",
   "metadata": {},
   "source": [
    "## 5. Random模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "c440dc44",
   "metadata": {},
   "outputs": [],
   "source": [
    "import random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "d0eddb3b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.5510818450002227"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# random. random方法：取（0，1）\n",
    "random. random()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "dc312a18",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "39"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# random. randint(a.b),随机生成a-b之间的一个数值\n",
    "random. randint(1,50)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "ffaa4557",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6\n",
      "4\n",
      "3\n",
      "1\n",
      "2\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    print(random.randint(1,6))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "1543c04e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# help random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "64f8e1c8",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "fe3c8f16",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello world\n"
     ]
    }
   ],
   "source": [
    "# 延迟3秒\n",
    "time.sleep(3)\n",
    "print(\"Hello world\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "37de91db",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "26"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "random.randint(10,60)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "06e6f4f1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "19\n",
      "现在是秒/时间为奇数\n",
      "20\n",
      "现在是秒/时间为偶数\n",
      "24\n",
      "现在是秒/时间为偶数\n",
      "26\n",
      "现在是秒/时间为偶数\n",
      "28\n",
      "现在是秒/时间为偶数\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "import time\n",
    "import random\n",
    "\n",
    "odds = [1, 3,  5,  7,  9,11,13,15,17,19,\n",
    "          21,23,25,27,29,31,33,35,37,39,\n",
    "          41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "for i in range(5):\n",
    "    right_this_minute = datetime.datetime.today().second\n",
    "    if right_this_minute in odds:\n",
    "        print(right_this_minute)\n",
    "        print(\"现在是秒/时间为奇数\")\n",
    "    else:\n",
    "        print(right_this_minute)\n",
    "        print(\"现在是秒/时间为偶数\")\n",
    "    time.sleep(random.randint(1,6))\n",
    "\n",
    "# 爬虫，爬数据，每隔 x 秒抓一次数据\n",
    "# 反爬虫，"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aa1510b4",
   "metadata": {},
   "source": [
    "## 课本P43实践"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "1cb305b6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 瓶 啤酒在墙上\n",
      "99 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "98 瓶 啤酒在墙上\n",
      "98 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "97 瓶 啤酒在墙上\n",
      "97 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "96 瓶 啤酒在墙上\n",
      "96 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "95 瓶 啤酒在墙上\n",
      "95 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "94 瓶 啤酒在墙上\n",
      "94 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "93 瓶 啤酒在墙上\n",
      "93 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "92 瓶 啤酒在墙上\n",
      "92 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "91 瓶 啤酒在墙上\n",
      "91 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "90 瓶 啤酒在墙上\n",
      "90 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "89 瓶 啤酒在墙上\n",
      "89 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "88 瓶 啤酒在墙上\n",
      "88 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "87 瓶 啤酒在墙上\n",
      "87 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "86 瓶 啤酒在墙上\n",
      "86 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "85 瓶 啤酒在墙上\n",
      "85 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "84 瓶 啤酒在墙上\n",
      "84 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "83 瓶 啤酒在墙上\n",
      "83 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "82 瓶 啤酒在墙上\n",
      "82 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "81 瓶 啤酒在墙上\n",
      "81 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "80 瓶 啤酒在墙上\n",
      "80 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "79 瓶 啤酒在墙上\n",
      "79 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "78 瓶 啤酒在墙上\n",
      "78 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "77 瓶 啤酒在墙上\n",
      "77 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "76 瓶 啤酒在墙上\n",
      "76 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "75 瓶 啤酒在墙上\n",
      "75 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "74 瓶 啤酒在墙上\n",
      "74 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "73 瓶 啤酒在墙上\n",
      "73 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "72 瓶 啤酒在墙上\n",
      "72 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "71 瓶 啤酒在墙上\n",
      "71 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "70 瓶 啤酒在墙上\n",
      "70 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "69 瓶 啤酒在墙上\n",
      "69 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "68 瓶 啤酒在墙上\n",
      "68 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "67 瓶 啤酒在墙上\n",
      "67 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "66 瓶 啤酒在墙上\n",
      "66 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "65 瓶 啤酒在墙上\n",
      "65 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "64 瓶 啤酒在墙上\n",
      "64 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "63 瓶 啤酒在墙上\n",
      "63 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "62 瓶 啤酒在墙上\n",
      "62 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "61 瓶 啤酒在墙上\n",
      "61 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "60 瓶 啤酒在墙上\n",
      "60 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "59 瓶 啤酒在墙上\n",
      "59 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "58 瓶 啤酒在墙上\n",
      "58 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "57 瓶 啤酒在墙上\n",
      "57 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "56 瓶 啤酒在墙上\n",
      "56 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "55 瓶 啤酒在墙上\n",
      "55 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "54 瓶 啤酒在墙上\n",
      "54 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "53 瓶 啤酒在墙上\n",
      "53 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "52 瓶 啤酒在墙上\n",
      "52 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "51 瓶 啤酒在墙上\n",
      "51 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "50 瓶 啤酒在墙上\n",
      "50 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "49 瓶 啤酒在墙上\n",
      "49 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "48 瓶 啤酒在墙上\n",
      "48 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "47 瓶 啤酒在墙上\n",
      "47 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "46 瓶 啤酒在墙上\n",
      "46 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "45 瓶 啤酒在墙上\n",
      "45 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "44 瓶 啤酒在墙上\n",
      "44 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "43 瓶 啤酒在墙上\n",
      "43 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "42 瓶 啤酒在墙上\n",
      "42 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "41 瓶 啤酒在墙上\n",
      "41 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "40 瓶 啤酒在墙上\n",
      "40 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "39 瓶 啤酒在墙上\n",
      "39 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "38 瓶 啤酒在墙上\n",
      "38 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "37 瓶 啤酒在墙上\n",
      "37 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "36 瓶 啤酒在墙上\n",
      "36 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "35 瓶 啤酒在墙上\n",
      "35 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "34 瓶 啤酒在墙上\n",
      "34 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "33 瓶 啤酒在墙上\n",
      "33 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "32 瓶 啤酒在墙上\n",
      "32 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "31 瓶 啤酒在墙上\n",
      "31 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "30 瓶 啤酒在墙上\n",
      "30 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "29 瓶 啤酒在墙上\n",
      "29 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "28 瓶 啤酒在墙上\n",
      "28 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "27 瓶 啤酒在墙上\n",
      "27 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "26 瓶 啤酒在墙上\n",
      "26 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "25 瓶 啤酒在墙上\n",
      "25 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "24 瓶 啤酒在墙上\n",
      "24 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "23 瓶 啤酒在墙上\n",
      "23 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "22 瓶 啤酒在墙上\n",
      "22 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "21 瓶 啤酒在墙上\n",
      "21 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "20 瓶 啤酒在墙上\n",
      "20 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "19 瓶 啤酒在墙上\n",
      "19 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "18 瓶 啤酒在墙上\n",
      "18 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "17 瓶 啤酒在墙上\n",
      "17 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "16 瓶 啤酒在墙上\n",
      "16 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "15 瓶 啤酒在墙上\n",
      "15 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "14 瓶 啤酒在墙上\n",
      "14 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "13 瓶 啤酒在墙上\n",
      "13 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "12 瓶 啤酒在墙上\n",
      "12 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "11 瓶 啤酒在墙上\n",
      "11 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "10 瓶 啤酒在墙上\n",
      "10 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "9 瓶 啤酒在墙上\n",
      "9 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "8 瓶 啤酒在墙上\n",
      "8 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "7 瓶 啤酒在墙上\n",
      "7 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "6 瓶 啤酒在墙上\n",
      "6 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "5 瓶 啤酒在墙上\n",
      "5 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "4 瓶 啤酒在墙上\n",
      "4 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "3 瓶 啤酒在墙上\n",
      "3 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "2 瓶 啤酒在墙上\n",
      "2 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "1 瓶 啤酒在墙上\n",
      "1 瓶 啤酒\n",
      "拿下一瓶\n",
      "传递它\n",
      "墙上没有啤酒啦\n",
      "0 瓶 啤酒在墙上\n",
      "\n"
     ]
    }
   ],
   "source": [
    "word = \"瓶\"\n",
    "for beer_num in range(99,0,-1):\n",
    "    print(beer_num, word, \"啤酒在墙上\")\n",
    "    print(beer_num, word, \"啤酒\")\n",
    "    print(\"拿下一瓶\")\n",
    "    print(\"传递它\")\n",
    "    \n",
    "    if beer_num == 1:\n",
    "        print(\"墙上没有啤酒啦\")\n",
    "\n",
    "else:\n",
    "\n",
    "    new_num = beer_num - 1\n",
    "\n",
    "    if new_num == 1:\n",
    "\n",
    "        word = \"瓶\"\n",
    "\n",
    "    print(new_num, word, \"啤酒在墙上\")\n",
    " \n",
    "print()\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "74338548",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "2dbddb97",
   "metadata": {},
   "source": [
    "## 6. 额外学习的内容：注释"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "40c04564",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
